package com.stitch.dcslock.service;

import com.stitch.dcslock.annotation.DistributedLock;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class DemoService {
    /**
     * 测试分布式锁的方法
     */
    @DistributedLock(key = "testLock", leaseTime = 30, waitTime = 5)
    public void doSomething() {
//        System.out.println("执行业务逻辑...");
        log.info("执行业务逻辑...");
        try {
            Thread.sleep(3000); // 模拟业务处理
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        log.info("业务逻辑执行完成...");
//        System.out.println("业务逻辑执行完成");
    }
}
